<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <script xmlns:th="http://www.w3.org/1999/html">
        //修改url里的某个查询变量的值，如果不存在这个查询变量，则添加这个变量和值
        function changeUrlArg(url, arg, val) {
            var pattern = arg + '=([^&]*)';
            var replaceText = arg + '=' + val;
            return url = url.match(pattern) ? url.replace(eval('/(' + arg
                + '=)([^&]*)/gi'), replaceText) : (url.match('[\?]') ? url
                + '&' + replaceText : url + '?' + replaceText);
        }
    </script>
</head>
<body>
<th:block th:if="${pagerItem != null}">
    <div class="paging">
        <div class="aleft" style="display: inline-block; float: left;">
            共<span th:text="${pagerItem.rowCount }"></span>行， </span>
            <span>
                <th:block th:with="pageSize=${pagerItem.paramPageSize},pageNum=${pagerItem.paramPageNum}">
                    <select th:attr="onchange=|location.href=changeUrlArg(changeUrlArg(location.href,'${pageSize}', this.options[this.options.selectedIndex].value),'${pageNum}', '1')|">
                        <th:block th:each="i:${#numbers.sequence(1,100)}">
                            <option th:text="${i}" th:selected="${pagerItem.pageSize == i}"></option>
                        </th:block>
                    </select>
                </th:block>
            行/页</span>
        </div>
        <div class="aright" style="display: inline-block; float: right;">
            <th:block
                th:with="isFirstPage = ${pagerItem.pageNum == 1},isLastPage=${pagerItem.pageNum == pagerItem.pageCount}">
                <th:block th:if="${isFirstPage }">
                    &nbsp;<span style="color:#ccc">首页</span>
                    &nbsp;<span style="color:#ccc">上一页</span>
                </th:block>
                <th:block th:unless="${isFirstPage}">
                    &nbsp;<span><a href="${pagerItem.firstPageUrl }"
                                   th:href="@{${pagerItem.firstPageUrl }}">首页</a></span>
                    &nbsp;<span><a href="${pagerItem.prevPageUrl }"
                                   th:href="@{${pagerItem.prevPageUrl }}">上一页</a></span>
                </th:block>
                    <th:block th:if="${isLastPage}">
                        &nbsp;<span style="color:#ccc">下一页 </span>
                        &nbsp;<span style="color:#ccc">尾页</span>
                    </th:block>
                <th:block th:unless="${isLastPage}">
                    &nbsp;<span><a href="${pagerItem.nextPageUrl }" th:href="@{${pagerItem.nextPageUrl }}"
                                   th:attr="onclick=|_ajx(${pagerItem.nextPageUrl })|">下一页</a></span>
                    &nbsp;<span><a href="${pagerItem.lastPageUrl }" th:href="@{${pagerItem.lastPageUrl }}">尾页</a></span>
                </th:block>
            </th:block>
            <span>&nbsp;&nbsp;&nbsp;&nbsp;跳到第
            <th:block th:with="pageNum=${pagerItem.paramPageNum}">
                <select th:attr="onchange=|location.href=changeUrlArg(location.href,'${pageNum}', this.options[this.options.selectedIndex].value)|">
                    <th:block th:each="i:${#numbers.sequence(1,pagerItem.pageCount)}">
                        <option th:value="${i}" th:selected="${pagerItem.pageNum == i}" th:text="${i}">1</option>
                    </th:block>
                 </select>
            </th:block>
            页 /共<span th:text="${pagerItem.pageCount }"></span>页</span>
        </div>
    </div>
</th:block>

</body>

